﻿using System;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace HYRElectric.PowerSystem
{
	[Regeneration(RegenerationOption.Manual)]
	[Transaction(TransactionMode.Manual)]
	public class CmdSystemDataManager : YJKCommandAuto
	{
		protected override Result YJKExcute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			try
			{
				using (DlgElectricSysManage dlgElectricSysManage = new DlgElectricSysManage(cmdData.Application.ActiveUIDocument.ActiveView.Document))
				{
                    if (dlgElectricSysManage.Result == Result.Failed)
					{
						return Autodesk.Revit.UI.Result.Failed;
					}
					dlgElectricSysManage.DialogResult = dlgElectricSysManage.ShowDialog();
					if (dlgElectricSysManage.DialogResult == DialogResult.Cancel)
					{
						return Autodesk.Revit.UI.Result.Succeeded;
					}
				}
			}
			catch (Exception)
			{
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
